import request from '@/utils/request'

// 语音记录数据结构
export interface VoiceRecordVO {
  id?: number
  userId?: number
  userName?: string
  bookId?: number
  bookTitle?: string
  pageNumber?: number
  voiceUrl?: string
  duration?: number
  status?: number
  reviewComment?: string
  createTime?: string
  updateTime?: string
}

// 语音记录统计数据结构
export interface VoiceRecordStatsVO {
  totalRecords: number
  pendingRecords: number
  approvedRecords: number
  todayNewRecords: number
}

// 查询语音记录列表
export const getVoiceRecordPage = (params: {
  current?: number
  size?: number
  userId?: number
  bookId?: number
  status?: number
}) => {
  return request({
    url: '/api/admin/voice-records',
    method: 'get',
    params
  })
}

// 获取语音记录详情
export const getVoiceRecord = (id: number) => {
  return request({
    url: `/api/admin/voice-records/${id}`,
    method: 'get'
  })
}

// 删除语音记录
export const deleteVoiceRecord = (id: number) => {
  return request({
    url: `/api/admin/voice-records/${id}`,
    method: 'delete'
  })
}

// 审核语音记录
export const reviewVoiceRecord = (id: number, params: {
  status: number
  reviewComment?: string
}) => {
  return request({
    url: `/api/admin/voice-records/${id}/review`,
    method: 'put',
    params
  })
}

// 获取语音记录统计数据
export const getVoiceRecordStats = () => {
  return request({
    url: '/api/admin/voice-records/stats',
    method: 'get'
  })
}

// 批量审核语音记录
export const batchReviewVoiceRecords = (params: {
  ids: string
  status: number
  reviewComment?: string
}) => {
  return request({
    url: '/api/admin/voice-records/batch-review',
    method: 'put',
    params
  })
}